home *** CD-ROM | disk | FTP | other *** search
/ fxPAINT 1.0 / fxPAINT 1.0.iso / developers / plugins / exampleplugin / lib_source / compiler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-19  |  4.5 KB  |  179 lines

  1. /*
  2. **      $VER: compiler.h 37.21 (19.12.97)
  3. **
  4. **      Compiler independent register (and SAS/C extensions) handling
  5. **
  6. **      (C) Copyright 1997 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #ifndef COMPILER_H
  11. #define COMPILER_H
  12.  
  13. /* Basically, Amiga C compilers must reach the goal to be
  14.    as SAS/C compatible as possible. But on the other hand,
  15.    when porting AmigaOS to other platforms, one perhaps
  16.    can't expect GCC becoming fully SAS/C compatible...
  17.  
  18.    There are two ways to make your sources portable:
  19.  
  20.     - using non ANSI SAS/C statements and making these
  21.       "available" to the other compilers (re- or undefining)
  22.     - using replacements for SAS/C statements and smartly
  23.       redefining these for any compiler
  24.  
  25.    The last mentioned is the most elegant, but may require to
  26.    rewrite your source codes, so this compiler include file
  27.    basically does offer both.
  28.  
  29.    For some compilers, this may have been done fromout project or
  30.    makefiles for the first method (e.g. StormC) to ensure compileablity.
  31.  
  32.    Basically, you should include this header file BEFORE any other stuff.
  33. */
  34.  
  35. /* ********************************************************************* */
  36. /* Method 1: redefining SAS/C keywords                                   */
  37. /*                                                                       */
  38. /* Sorry, this method does not work with register definitions for the current
  39. gcc version (V2.7.2.1), as it expects register attributes after the parameter
  40. description. (This is announced to be fixed with gcc V2.8.0).
  41. Moreover the __asm keyword has another meaning with GCC.
  42. Therefore ASM must be used. */
  43.  
  44. #ifdef __MAXON__  // ignore this switches of SAS/Storm
  45. #define __aligned
  46. #define __asm
  47. #define __regargs
  48. #define __saveds
  49. #define __stdargs
  50. #endif
  51.  
  52. #ifdef __GNUC__  // ignore this switches of SAS/Storm
  53. #define __d0
  54. #define __d1
  55. #define __d2
  56. #define __d3
  57. #define __d4
  58. #define __d5
  59. #define __d6
  60. #define __d7
  61. #define __a0
  62. #define __a1
  63. #define __a2
  64. #define __a3
  65. #define __a4
  66. #define __a5
  67. #define __a6
  68. #define __a7
  69. #endif
  70.  
  71. #ifdef VBCC
  72. #define __d0 __reg("d0")
  73. #define __d1 __reg("d1")
  74. #define __d2 __reg("d2")
  75. #define __d3 __reg("d3")
  76. #define __d4 __reg("d4")
  77. #define __d5 __reg("d5")
  78. #define __d6 __reg("d6")
  79. #define __d7 __reg("d7")
  80. #define __a0 __reg("a0")
  81. #define __a1 __reg("a1")
  82. #define __a2 __reg("a2")
  83. #define __a3 __reg("a3")
  84. #define __a4 __reg("a4")
  85. #define __a5 __reg("a5")
  86. #define __a6 __reg("a6")
  87. #define __a7 __reg("a7")
  88. #endif
  89.  
  90.  /* for SAS/C we don't need this, for StormC this is done in the
  91.     makefile or projectfile */
  92.  
  93. /*                                                                       */
  94. /* ********************************************************************* */
  95.  
  96.  
  97. /* ********************************************************************* */
  98. /* Method 2: defining our own keywords                                   */
  99. /*                                                                       */
  100. #ifdef __SASC
  101.  
  102. #  define REG(r)     register __ ## r
  103. #  define GNUCREG(r)
  104. #  define SAVEDS     __saveds
  105. #  define ASM        __asm
  106. #  define REGARGS    __regargs
  107. #  define STDARGS    __stdargs
  108. #  define ALIGNED    __aligned
  109.  
  110. #else
  111. # ifdef __MAXON__
  112.  
  113. #   define REG(r)    register __ ## r
  114. #   define GNUCREG(r)
  115. #   define SAVEDS
  116. #   define ASM
  117. #   define REGARGS
  118. #   define STDARGS
  119. #   define ALIGNED
  120.  
  121. # else
  122. #   ifdef __STORM__
  123.  
  124. #     define REG(r)  register __ ## r
  125. #     define GNUCREG(r)
  126. #     define SAVEDS  __saveds
  127. #     define ASM
  128. #     define REGARGS
  129. #     define STDARGS
  130. #     define ALIGNED
  131.  
  132. #   else
  133. #     ifdef __GNUC__
  134.  
  135. #       define REG(r)
  136. #       define GNUCREG(r)  __asm( #r )
  137. #       define SAVEDS  __saveds
  138. #       define ASM
  139. #       define REGARGS __regargs
  140. #       define STDARGS __stdargs
  141. #       define ALIGNED __aligned
  142.     
  143. #   else    
  144. #     ifdef VBCC
  145. /* VBCC ignore this switch */
  146. #    define __aligned
  147. #    define __asm
  148. #    define __regargs
  149. #    define __saveds
  150. #    define __stdargs
  151. #    define __register
  152. #    define GNUCREG(r)
  153. #    define REG(r)
  154. #       define SAVEDS
  155. #       define ASM
  156. #       define REGARGS
  157. #       define STDARGS
  158. #       define ALIGNED
  159.  
  160. #     else /* any other compiler, to be added here */
  161.  
  162. #       define REG(r)
  163. #       define GNUCREG(r)
  164. #       define SAVEDS
  165. #       define ASM
  166. #       define REGARGS
  167. #       define STDARGS
  168. #       define ALIGNED
  169.  
  170. #      endif /*  VBCC  */
  171. #     endif /* __GNUC__ */
  172. #   endif /* __STORM__ */
  173. # endif /* __MAXON__ */
  174. #endif /* __SASC */
  175. /*                                                                       */
  176. /* ********************************************************************* */
  177.  
  178. #endif /* COMPILER_H */
  179.